import { Controller, Query, Get, Body, Post } from '@nestjs/common';
import { WebCommentService } from './web-comment.service';
import { CreateCommentDto } from './dto/create-web-comment.dto';

@Controller('web-comment')
export class WebCommentController {
    constructor(private readonly webCommentService: WebCommentService) { }

    @Get()
    list (@Query() urlQuery: { articleId: string, pageIndex: string, pageSize: string }) {
        const query = {
            articleId: +urlQuery.articleId,
            pageIndex: +urlQuery.pageIndex,
            pageSize: +urlQuery.pageSize
        }
        return this.webCommentService.list(query)
    }

	@Get('count')
    getCount () {
        return this.webCommentService.getCount()
    }

    @Post()
    create(@Body() createCommentDto: CreateCommentDto) {
        return this.webCommentService.create(createCommentDto);
    }
}
